function pickDetail(goodsId, totalNum, outBoundId,
    goodsName, specificationName) {//商品规格id，应捡取数量，商品名称，商品规格
    $("#totalNum").val(totalNum);
    $("#goodsName").val(goodsName);
    $("#spec").val(specificationName);
    layui.use(['table', 'layer', 'form', 'layedit'], function () {
        //var $ = layui.jquery;
        var layer = layui.layer;
        var table = layui.table;
        var form = layui.form;
        var layedit = layui.layedit;
        var reg = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/;//正整数的正则表达式
        //第一个实例
        table.render({
            elem: '#test'
            , id: 'testReload'
            , where: { goodsId: goodsId }
            , url: 'jay/GoodsAllocation/getGaById' //数据接口
            , parseData: function (res) {
                return {
                    "code": 0, //解析接口状态
                    "msg": "", //解析提示文本
                    "count": res.obj.total, //解析数据长度
                    "data": res.obj.list //解析数据列表
                };
            }
            , toolbar: '#toolbarDemo'
            , defaultToolBar: ['default', 'print', 'export']
            , page: true //开启分页
            , limit: 10
            , cols: [[ //表头
                { field: 'id', title: '序号', align: 'center', width: 100, fixed: 'left', sort: true, totalRowText: '原始合计' }
                , { field: 'goodsAllocationCode', title: '仓库-货架-层-格', align: 'center', width: 160 }
                , { field: 'quantityOfGoods', title: '货物数量', align: 'center', width: 100 }
                , { field: 'takeNum', title: '取货数', align: 'center', width: 100, edit: 'text', totalRow: true }
                , { field: 'maxStorage', title: '存储上限', align: 'center', width: 160, }
                , { fixed: 'right', toolbar: '#bar1', title: '操作', align: 'center' }
            ]]
        });
        var $ = layui.$, active = {
            reload: function () {
                table.reload('testReload', {
                    page: {
                        curr: 1//默认从第一页开始加载
                    },
                    where: {
                        goodsId: goodsId,
                        goodsAllocationCode: $("#goodsAllocationCode").val()
                    }
                });
            }
        };
        $('#find').on('click', function () {
            $("#test2").html("");
            $("#total").val("");
            var type = 'reload';
            active[type] ? active[type].call(this) : '';
        });
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            if (obj.event = 'detail') {
                if (data.takeNum == undefined) {
                    layer.msg("请选择货物数量!", { icon: 2 });
                } else if (data.takeNum != undefined && !reg.test(data.takeNum)) {
                    layer.msg("请输入有效数量!", { icon: 2 });
                } else if (data.takeNum > data.quantityOfGoods || data.takeNum < 1) {
                    layer.msg("拿取数量无效，确认库存!", { icon: 2 });
                } else {
                    var length = document.getElementById("test2").rows.length;
                    if (length == 0) {
                        var $tr = "<tr>\n" +
                            "                                                    <td>1</td>\n" +
                            "                                                    <input type=hidden' value='1'>\n" +
                            "                                                    <td>" +
                            "                                                      " + data.goodsAllocationCode + "" +
                            "                                                       <input type='hidden' id='goodsAllocationCode1' value='" + data.goodsAllocationCode + "'>" +//货位编码
                            "                                                       <input type='hidden' id='id1' value='" + data.id + "'>" +//仓库id
                            "                                                   </td>\n" +
                            "                                                    <td>" + data.takeNum + "</td>\n" +
                            "                                                       <input type='hidden' id='takeNum1' value='" + data.takeNum + "'>" +//拿取数量
                            "                                                </tr>";
                        $("#test2").append($tr);
                    } else if (length > 0 && length < 8) {
                        var $tr = "<tr>\n" +
                            "                                                    <td>" + (length + 1) + "</td>\n" +
                            "                                                    <input type=hidden' value='1'>\n" +
                            "                                                    <td>" +
                            "                                                      " + data.goodsAllocationCode + "" +
                            "                                                       <input type='hidden' id='goodsAllocationCode" + (length + 1) + "' value='" + data.goodsAllocationCode + "'>" +//货位编码
                            "                                                       <input type='hidden' id='id" + (length + 1) + "' value='" + data.id + "'>" +//仓库id
                            "                                                   </td>\n" +
                            "                                                    <td>" + data.takeNum + "</td>\n" +
                            "                                                       <input type='hidden' id='takeNum" + (length + 1) + "' value='" + data.takeNum + "'>" +//拿取数量
                            "                                                </tr>";
                        $("#test2").append($tr);
                    } else if (length > 7) {
                        layer.msg("每个商品每次最多生成8条拣货任务", { icon: 2 });
                        return "";
                    }
                    obj.update({
                        quantityOfGoods: data.quantityOfGoods - data.takeNum,
                        takeNum: 0
                    });
                    var newTotal = 0;
                    length = document.getElementById("test2").rows.length;
                    for (var i = 1; i <= length; i++) {
                        newTotal = newTotal + $("#takeNum" + i).val() * 1;
                    }
                    $("#total").val(newTotal);
                    $("#oldTotal").val(newTotal);
                }
            }
        });
        form.on('submit(handin)', function (data) {
            layer.confirm("确认要生成出库任务吗?", { btn: ["确认", "取消"] }, function () {
                if ($("#total").val() != totalNum) {
                    layer.msg("未完成应出库数量", { icon: 2 });
                } else {
                    var arr = [];
                    var info;
                    var length = document.getElementById("test2").rows.length;//获取表格长度
                    for (var i = 1; i <= length; i++) {
                        info = {
                            "goodsId": goodsId,
                            "outBoundId": outBoundId,
                            "quantityOfGoods": $("#takeNum" + i).val(),
                            "shelfId": $("#id" + i).val()
                        };
                        arr.push(info);//添加拣货明细对象
                    }
                    console.log(info);
                    var pickOrderUtil = {
                        "list": arr,
                        "outBoundId": outBoundId,
                        "goodsId": goodsId
                    };
                    $.ajax({
                        url: "jay/PickOrder/addPickOrderDetail",
                        contentType: "application/json;charset=UTF-8;",
                        data: JSON.stringify(pickOrderUtil),
                        type: "post",
                        traditional: true,
                        dataType: "json",
                        success: function (data) {
                            if (data.obj == null || data.obj == 0) {
                                layer.msg("生成拣货任务失败,请稍后再试", { icon: 2 });
                            } else {
                                layer.msg("成功生成拣货任务", { icon: 1 });
                                setTimeout(function () {
                                    location.href = 'chuku.html';
                                }, 500);
                            }
                        }
                    })
                }
            }, function () {
                layer.msg("您取消了操作", { icon: 2 });
            })
        });
    });
}